package com.itcam.servlet_.loginmodel.control;


import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * Author:Cammy.Wu
 * Date:2024-06-27
 * Description:
 */

public class PageServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("接收到客户端的请求，返回响应的登录页面");
        // 设置响应编码
        resp.setContentType("text/html;charset=utf-8");
        // 获取响应的输出流对象
        PrintWriter out = resp.getWriter();
        out.write("<html>");
        out.write("<head>");
        out.write("<title>登录页面</title>");
        out.write("</head>");
        out.write("<body>");
        out.write("<form action='/login' method='get'>");
        out.write("<input type='text' name='username' placeholder='用户名'/>");
        out.write("<input type='password' name='password' placeholder='密码'/>");
        out.write("<input type='submit' value='登录'/>");
        out.write("</form>");
        out.write("</body>");
        out.write("</html>");
    }
}
